package uk.co.q3c.deplan.server.unit.dao;

import java.io.Serializable;

import javax.persistence.Id;

import uk.co.q3c.deplan.client.domain.AbstractDomainObject;
import uk.co.q3c.deplan.client.domain.DomainKind;
import uk.co.q3c.deplan.client.domain.DomainObject;
import uk.co.q3c.deplan.client.domain.resource.PersistenceReferenceException;
import uk.co.q3c.deplan.client.service.ServiceFactory;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Indexed;
import com.googlecode.objectify.annotation.Unindexed;

@Unindexed
@Cached(expirationSeconds = 600)
public class SimpleDomainObject extends AbstractDomainObject implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	private Long keyId;

	public static final int classId = 1999;

	public SimpleDomainObject(ServiceFactory connection) {
		super(connection);
	}

	@Indexed
	private int intValue;
	@Indexed
	private String tag;

	protected SimpleDomainObject() {

	}

	public SimpleDomainObject(ServiceFactory connection, int intValue) {
		super(connection);
		this.intValue = intValue;
	}

	// (mappedBy = "simple")
	// private ComplexDomainObject owner;

	public int getIntValue() {
		return intValue;
	}

	public void setIntValue(int intValue) {
		this.intValue = intValue;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	// @Override
	// public String toString() {
	// if (getKey() == null) {
	// return getClass().getSimpleName() + "with null key";
	// }
	// return getKey().toString();
	// }

	@Override
	public DomainKind getKind() {
		return DomainKind.SimpleDomainObject;
	}

	public Long getKeyId() {
		return keyId;
	}

	@Override
	public Key<? extends DomainObject> getKey() throws PersistenceReferenceException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setKeyId(Long keyId) {
		// TODO Auto-generated method stub

	}

}
